package cn.rwklyd.BookKeeping.controller;

import cn.rwklyd.BookKeeping.pojo.Result;
import cn.rwklyd.BookKeeping.pojo.vo.TransactionStatsVO;
import cn.rwklyd.BookKeeping.service.TransactionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/transaction/stats")
@Tag(name = "记账统计", description = "用户记账统计信息接口")
@Slf4j
public class TransactionStatsController {

    @Autowired
    private TransactionService transactionService;

    /**
     * 获取用户记账统计信息
     */
    @GetMapping
    @Operation(summary = "获取统计信息", description = "获取当前用户的记账总数、记账天数和连续记账天数")
    @PreAuthorize("hasAuthority('view_users')")
    public Result<TransactionStatsVO> getUserTransactionStats() {
        log.info("获取用户记账统计信息");
        return transactionService.getUserTransactionStats();
    }
} 